package iuhao.controller;

import com.iuhao.redis.O2ORedisTemplate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import iuhao.common.response.O2OJSON;
import iuhao.model.Man;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by yanhao on 2017/10/16.
 */
@Api(tags = "ManagerController", description = "ManagerController")
@RestController
@RequestMapping("/manager")
public class ManagerController {

    @Autowired
    private O2ORedisTemplate o2ORedisTemplate;

    @ResponseBody
    @ApiOperation(value = "测试")
    @RequestMapping(value = "/test1", method = RequestMethod.GET)
    public O2OJSON jedisTest(HttpServletRequest request, HttpServletResponse response) {
        O2OJSON json = new O2OJSON();
        HashMap<Object, Object> map = new HashMap<>();
        Man man = new Man();
        man.setAge(25);
        man.setName("豪哥");
        o2ORedisTemplate.put("iuhao2017","18300684211");
        o2ORedisTemplate.put("1992iuhao",man);
        Object s1 = o2ORedisTemplate.get("1992iuhao");
        String s = o2ORedisTemplate.get("iuhao2017");
        map.put("s1",s1);
        map.put("s",s);
        json.setData(map);
        return  json;
    }
}
